<template>
  <div class="children-management">
    <h3>{{ $t('message.childrenManagement') }}</h3>
    <p>{{ $t('message.manageChildrenInfo') }}</p>
    
    <div class="children-list">
      <el-table :data="children" style="width: 100%" stripe>
        <el-table-column prop="name" :label="$t('message.name')" width="150" />
        <el-table-column prop="grade" :label="$t('message.gradeLevel')" width="150" />
        <el-table-column prop="school" :label="$t('message.school')" width="200" />
        <el-table-column prop="age" :label="$t('message.age')" width="100" />
        <el-table-column prop="enrollmentDate" :label="$t('message.enrollmentDate')" width="150" />
        <el-table-column :label="$t('message.actions')" width="200">
          <template #default="scope">
            <el-button size="small" @click="viewChild(scope.row)">{{ $t('message.view') }}</el-button>
            <el-button size="small" type="primary" @click="updateChild(scope.row)">{{ $t('message.update') }}</el-button>
            <el-button size="small" type="danger" @click="removeChild(scope.row)">{{ $t('message.remove') }}</el-button>
          </template>
        </el-table-column>
      </el-table>
    </div>
  </div>
</template>

<script>
import { ref, onMounted } from 'vue';
import { ElMessage } from 'element-plus';
import { useI18n } from 'vue-i18n';

export default {
  name: 'ChildrenManagement',
  setup() {
    const { t } = useI18n();
    const children = ref([
      {
        id: 1,
        name: '张小明',
        grade: '小学三年级',
        school: '阳光小学',
        age: 8,
        enrollmentDate: '2024-09-01'
      },
      {
        id: 2,
        name: '李小红',
        grade: '小学五年级',
        school: '蓝天小学',
        age: 10,
        enrollmentDate: '2024-09-01'
      }
    ]);

    const viewChild = (child) => {
      ElMessage.info(`${t('message.viewing')} ${child.name}`);
    };

    const updateChild = (child) => {
      ElMessage.success(`${t('message.updating')} ${child.name}`);
    };

    const removeChild = (child) => {
      ElMessage.warning(`${t('message.removing')} ${child.name}`);
    };

    onMounted(() => {
      console.log('Children management component mounted');
    });

    return {
      children,
      viewChild,
      updateChild,
      removeChild,
      t
    };
  }
};
</script>

<style scoped>
.children-management {
  padding: 20px;
}

.children-list {
  margin-top: 20px;
}
</style>